Skip to content

Conversation

@jmschonfeld
Copy link
Contributor

This applies changes from #908 to all files for which the changes apply cleanly which covers a significant number of tests. I'll come back with separate PRs to update the patches for files that have changed since the initial audit, but this updates all suites that cleanly apply.

The main change from #908 is how we handle tests that read or mutate the current Locale/TimeZone/Calendar. Instead of using a parent suite to serialize these tests, we use a global actor which tests await work on that depends on these values. The global actor also ensures that the current Calendar/Locale/TimeZone are reset back to their default values after each test to ensure mutations from one test don't have any interactions with future tests. Since XCTest tests all run before swift-testing tests begin, it's ok that XCTests that have yet to be converted might mutate this state while we're working to convert everything over.

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

#expect(weekDayStyle.format(date..<date + day) == "Mon – Tue")
#expect(weekDayStyle.format(date..<date + day * 32) == "Mon – Fri")
// This style doesn't really make sense since the gap between `weekDay` and `hour` makes the result AMbiguous. ICU fills the missing pieces on our behalf.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if intentional but this is kinda punny and I like it 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha sadly I can't claim credit for this one, no idea how that happened - it must have somehow been one of my regex copy and pastes gone wrong back with the original patch. But I agree the pun is great haha

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kudos to @jrflat for finding a punneedle in this haystack of changes

#expect(weekDayStyle.format(date..<date + day) == "Mon – Tue")
#expect(weekDayStyle.format(date..<date + day * 32) == "Mon – Fri")
// This style doesn't really make sense since the gap between `weekDay` and `hour` makes the result AMbiguous. ICU fills the missing pieces on our behalf.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kudos to @jrflat for finding a punneedle in this haystack of changes

private struct GregorianCalendarInternationalizationTests {
@Test func copy() {
let gregorianCalendar = _CalendarGregorian(identifier: .gregorian, timeZone: nil, locale: nil, firstWeekday: 5, minimumDaysInFirstWeek: 3, gregorianStartDate: nil)
let gregorianCalendar = _CalendarGregorian(identifier: .gregorian, timeZone: .gmt, locale: nil, firstWeekday: 5, minimumDaysInFirstWeek: 3, gregorianStartDate: nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a note to myself, but we should probably lift this logic of falling back to the current time zone out of _CalendarGregorian :/ Seems like a footgun even just for unit tests

@jmschonfeld jmschonfeld merged commit eb084da into swiftlang:main Jun 26, 2025
16 checks passed
@jmschonfeld jmschonfeld deleted the swift-testing/i18n branch June 26, 2025 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants